from flask import Flask,render_template
from pyecharts.charts import Line
from pyecharts import options as opts
import pandas as pd
from picture import totalnumpage,laodonglinumpage,total,nanpage,nvpage,progdp,indgdp,woker,industry,cityzx

app = Flask(__name__)


@app.route('/')
def homepage():
    ''''''
    return render_template('首页.html')

@app.route('/map')
def mappage():
    '''主题1 地图'''
    return render_template('主题1全国地图.html')

@app.route('/totalnum')
def totalnumzx():
    '''主题2 人口总数'''
    totalnumpage()
    with open("templates/中国总人口历史变化.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题2人口总数.html',the_plot_all=plot_all)

@app.route('/laodonglinum')
def laodonglinumzx():
    '''主题2 劳动力总数'''
    laodonglinumpage()
    with open("templates/中国劳动力人口历史变化.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题2劳动力总数.html',the_plot_all=plot_all)

@app.route('/2zonglan')
def zonglanzx():
    '''主题2 劳动力总览'''
    total()
    with open("templates/中国劳动力变化折线图堆叠.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题2总览.html',the_plot_all=plot_all)

@app.route('/nanxing')
def nanxingzx():
    '''主题3 男性人口总数'''
    nanpage()
    with open("templates/中国男性人口历史变化.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题3男性.html',the_plot_all=plot_all)

@app.route('/nvxing')
def nvxingzx():
    '''主题3 女性人口总数'''
    nvpage()
    with open("templates/中国女性人口历史变化.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题3女性.html',the_plot_all=plot_all)

@app.route('/propage')
def pro():
    '''主题4 Top10省GDP增加值'''
    progdp()
    with open("templates/1992-2020年Top10省GDP增加值数据.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题4省GDP.html',the_plot_all=plot_all)

@app.route('/indpage')
def ind():
    '''主题4 Top10行业GDP增加值'''
    indgdp()
    with open("templates/1992-2020TOP10行业GDP增加值数据堆叠.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题4行业GDP.html',the_plot_all=plot_all)

@app.route('/jiuyepage')
def jiuye():
    '''主题5 三大产业就业人数'''
    woker()
    with open("templates/三大产业就业折线图堆叠.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题5就业.html',the_plot_all=plot_all)

@app.route('/chanyepage')
def chanye():
    '''主题5 三大产业占比'''
    industry()
    with open("templates/三大产业占比.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题5产业.html',the_plot_all=plot_all)

@app.route('/citypage')
def city():
    '''主题6 城镇'''
    cityzx()
    with open("templates/2004-2019年城镇私营与非私营就业人口分布.html", encoding="utf8", mode="r") as f:
        plot_all = "".join(f.readlines())
    return render_template('主题6城镇.html',the_plot_all=plot_all)

if __name__ == '__main__':
    app.run()
